import { resolveComponent } from "vue";
import {Ptext} from "../../index"
export default (props, context) => {
  const { slots, attrs, emit } = context;
  const { columns, data } = props;

  console.log(props);
  return (
    <el-table {...attrs}>
      {props.columns.map((column) => {
        const { component, prop, render, ...colProps } = column;
        if (render) {
          // const Component = resolveComponent(component);
          // console.log(prop)
          return (
            <el-table-column
              {...colProps}
              prop={prop}
              v-slots={{
                default: (scope) => (
                  render(scope)
                  // <Component>
                  //   {scope.row?.[prop] || "/"}
                  // </Component>
                ),
              }}
            />
          );
        }

        return <el-table-column {...colProps}
          v-slots={{
            default: (scope) => (
              <Ptext text={scope.row?.[prop]} />
            ),
          }}
        >

          </el-table-column>;
      })}
    </el-table>
  );
};
